import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;

public class OrderServicePool extends BasePooledObjectFactory<OrderService> {

    @Override
    public OrderService create() throws Exception {
        return new OrderService();
    }

    @Override
    public PooledObject<OrderService> wrap(OrderService orderService) {
        return new DefaultPooledObject<OrderService>(orderService);
    }

    /**
     * When an object is returned to the pool, clear the buffer.
     */
    @Override
    public void passivateObject(PooledObject<OrderService> pooledObject) {
        pooledObject.getObject();
    }
}
